#include "image.h"

roImage::roImage()
{
	roPreImage::roPreImage();
}
roImage::roImage(roImage* source)
{
	roImage(source->data(), source->width(), source->height());
}

roImage::roImage(roPreImage* source)
{
	roPreImage::roPreImage(source);
}

roImage::roImage(uchar* data, uint width, uint height)
{
	replace(data, width, height);
}

roImage::roImage(uchar* R, uchar* G, uchar* B, uint width, uint height)
{
	uchar* data = new uchar[width * height * 3];
	long pos, xy;

    for(uint y = 0; y < height; y++)
        for(uint x = 0; x < width; x++)
        {
            xy = (y * width + x);
			pos = xy * 3;

            data[pos] = R[xy];
			data[pos+1] = G[xy];
			data[pos+2] = B[xy];
        }
	replace(data, width, height);
}


uchar* roImage::pixel(uchar red, uchar green, uchar blue, uint x, uint y)
{
	long pos = (y * m_width + x) * 3;
	m_data[pos] = red;
	m_data[pos + 1] = green;
	m_data[pos + 2] = blue;
	return m_data + pos;
}

uchar* roImage::red()
{
	return chanel(roConvert::Red);
}

uchar* roImage::green()
{
	return chanel(roConvert::Green);
}

uchar* roImage::blue()
{
	return chanel(roConvert::Blue);
}





